package com.aivin.lib_media.myMp3Player;



public class WordReadTool {
    private MediaPlayerHolder mediaPlayerIngHolder  ;

    public  WordReadTool(){
        if(mediaPlayerIngHolder==null){
            mediaPlayerIngHolder = new MediaPlayerHolder( ) ;

            PlaybackInfoListener playbackInfoListener = new PlaybackInfoListener() {

                @Override
                public void onPositionChanged(int position, int duration, boolean isFirst) {

                }

                @Override
                public void onStateChanged(int state) {
                    if (state == PlayerStatus.STATUS_PREPARED) {
                        mediaPlayerIngHolder.play();
                    }
                }

                @Override
                public void onPlaybackCompleted() {

                }
            };
            mediaPlayerIngHolder.setmPlaybackInfoListener(playbackInfoListener);
        }
    }

    public void readThWord(String url){
        if(mediaPlayerIngHolder!=null){
            mediaPlayerIngHolder.loadMedia(url);
        }
    }


    public void release(){
        if(mediaPlayerIngHolder!=null){
            mediaPlayerIngHolder.release();
            mediaPlayerIngHolder = null;
        }
    }
}
